<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Login Page</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 样 式 文 件 -->
    <link rel="stylesheet" href="{_STATIC_PATH}component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form layui-form-pane" lay-filter="lotus-edit-filter">

    <div class="layui-form-item" style="display: none">
        <label class="layui-form-label">id</label>
        <div class="layui-input-block">
            <input type="text" name="id" lay-verify="required" value=""
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">
            角色分配
        </label>
        <div class="layui-input-block">
            <select name="group_id">
                <option value="0"></option>
                {volist name='group' id='vo'}
                <option value="{$vo.id}">{$vo.title}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">用户密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" value=""
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input type="number" value="0" name="phone" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div>{:token_field()}</div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn layui-btn-submit" lay-submit lay-filter="save">提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script src="{_STATIC_PATH}component/layui/layui.js"></script>
<script src="{_STATIC_PATH}component/pear/pear.js"></script>
<script>
    layui.use(['form', "iconPicker", "jquery"], function () {
        var form = layui.form,
            $ = layui.jquery;

        var data = {
            "id": "{$data.id}",
            'name': "{$data.name}",
            "phone": "{$data.phone}",
            "group_id": "{$data.group_id}",
        };
        form.val("lotus-edit-filter", data);
        form.on('submit(save)', function (data) {
            $.ajax({
                url: '',
                type: "post",
                data: data.field,
                success: function (result) {
                    if (result.status == "1") {
                        layer.msg(result.message, function () {
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(result.message);
                    }
                }
            })
        });
    });
</script>
</body>
</html>